Home

Operator Usage

Name

(*,*)

Description

(*)
(*,*)
(*,*,*)
(*,*,*,*)
anonymous or unbound function symbol
used to define a function, but without binding the variables to an op-ket
instead, the input variables bind to |__selfk>, where k is a positive integer
note that the input sequence binds to |__self0>
the first param binds to |__self> or |__self1>
the second param to |__self2>, and so on
currently limited to a max of 4 parameters, bound functions in contrast do not have this limit
in many cases, bound functions are now preferred over anonymous functions


Examples

-- anonymous function with 1 parameter:
fn1 (*) #=> 2|__self0> + 3|__self1>

-- anonymous function with 2 parameters:
fn2 (*,*) #=> 2|__self0> + 3|__self1> + 5|__self2>

-- anonymous function with 3 parameters:
fn3 (*,*,*) #=> 2|__self0> + 3|__self1> + 5|__self2> + 7|__self3>

-- anonymous function with 4 parameters:
fn4 (*,*,*,*) #=> 2|__self0> + 3|__self1> + 5|__self2> + 7|__self3> + 11|__self4>


-- another example, this time a multi-line rule:
foo2 (*,*) #=>
    sprint["input: "] |__self0>
    sprint["one: "] |__self1>
    sprint["two: "] |__self2>
    |return var>

-- now invoke it:
foo2(ssplit |abc>, ssplit |uv>) ssplit |xyz>

    input: |x> . |y> . |z>
    one: |a> . |b> . |c>
    two: |u> . |v>
    |return var>


See also

Operator type

miscellaneous element